//
//  MessageTableViewCell.m
//  WideHelp
//
//  Created by ENERGY on 2018/8/8.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MessageTableViewCell.h"

@interface MessageTableViewCell()
@property (nonatomic, strong)UIImageView * iconImg;
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UILabel * contentLab;
@property (nonatomic, strong)UILabel * dataLab;
@property (nonatomic, strong)UIView * lineView;
@end

@implementation MessageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor whiteColor];
        __weak typeof (self)weakSelf = self;
        [self.contentView addSubview:self.iconImg];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.dataLab];
        [self.contentView addSubview:self.contentLab];
        [self.contentView addSubview:self.lineView];
        int iconImgW = 30/WIDTH_6_SCALE;
        [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(22/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(15/WIDTH_6_SCALE);
            make.width.height.mas_offset(iconImgW);
        }];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(13/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.iconImg.mas_right).mas_offset(15/WIDTH_6_SCALE);
            make.height.mas_offset(14/WIDTH_6_SCALE);
        }];
        [self.dataLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView.mas_top).mas_offset(15/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-16/WIDTH_6_SCALE);
            make.height.mas_equalTo(13/WIDTH_6_SCALE);
        }];
        [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.titleLab.mas_bottom).mas_offset(11/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.titleLab.mas_left);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-68/WIDTH_6_SCALE);
        }];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentLab.mas_bottom).mas_offset(13/WIDTH_6_SCALE);
            make.height.mas_equalTo(1/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.iconImg.mas_right).mas_offset(15/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.contentView);
            make.bottom.equalTo(weakSelf.contentView.mas_bottom);
        }];
    }return self;
}

- (UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [[UIImageView alloc] init];
//        _iconImg.backgroundColor = [UIColor orangeColor];
        _iconImg.image = [UIImage imageNamed:@"head_login_icon"];
    }return _iconImg;
}

- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(@"eeeeee");
    }return _lineView;
}

- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = DEF_FontSize_14;
        _titleLab.textColor = [UIColor blackColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.text = @"系统升级";
    }return _titleLab;
}

- (UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] init];
        _contentLab.font = DEF_FontSize_13;
        _contentLab.textColor = getColor(@"9b9b9b");
        _contentLab.textAlignment = NSTextAlignmentLeft;
        _contentLab.text = @"分享的时候照片的选取与删除以及文字的分享分享的时候照片的选取与删除以及文字的分享分享的时候照片的选取与删除以及文字的分享分享的时候照片的选取与删除以及文字的分享分享的时候照片的选取与删除以及文字的分享";
        _contentLab.numberOfLines = 0;
        _contentLab.lineBreakMode = 0;
    }return _contentLab;
}

- (UILabel *)dataLab{
    if (!_dataLab) {
        _dataLab = [[UILabel alloc] init];
        _dataLab.font = DEF_FontSize_13;
        _dataLab.text = @"前天";
        _dataLab.textColor = [UIColor blackColor];
        _dataLab.textAlignment = NSTextAlignmentRight;
    }return _dataLab;
}

- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.contentLab.text = model[@"content"];
//    if ([model[@"unit_img"] isEqualToString:@""]) {
//        self.iconImg.image = [UIImage imageNamed:@"maself_bg"];
//    }else{
//        [self.iconImg sd_setImageWithURL:[NSURL URLWithString:model[@"unit_img"]]];
//    }
    
}
@end
